﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;

namespace QUANLIBANHANG.GUI
{
   public class Fileexcel
    {
      private OleDbConnection con;

       public Fileexcel()
       { }
       // Lấy dử liẹu từ excel
       public DataTable getTableExcel(string path, string sql)
       {
          DataTable dt = new DataTable();
          con = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+";Extended Properties=Excel 8.0;");
          try
          {
              con.Open();
              OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
              da.Fill(dt);
              con.Close();
          }
          catch (Exception ex)
          {
              
              throw ex;
          }
          
          return dt;
           
       }

       
    }
}
